<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<%@ include file="/Dmyna/head.jsp"%>

<%
String cartListCode = "";
String cartListCnt = "";
String cartListColor = "";
String cartListSize = "";
int loopCartCnt = 0;
%>

<c:set var="cartListCode" value="" />
<c:set var="cartListCnt" value="" />
<c:set var="cartListColor" value="" />
<c:set var="cartListSize" value="" />

<table width="900" align=center cellpadding=0 cellspacing=0>
<tr>
	<td>
		<div
			style="border:1px solid #ddd; height:34px; background:url(${WEB_ROOT }/img/bbs/title_bg.gif) repeat-x;">
			<div style="font-weight: bold; font-size: 14px; margin: 7px 0 0 10px;" align="center">
				::&nbsp;&nbsp;장바구니 리스트&nbsp;&nbsp;::
			</div>
		</div>
	</td>
</tr>
</table>
<br />

<table width="900" align="center" cellpadding="0" cellspacing="0">
<tr>
	<td>
		<table width="900" align=center cellspacing="0" cellpadding="0" class="board_list">
		<col width="100" />
		<col />
		<col width="100" />
		<col width="100" />
		<col width="100" />

		<tr>
			<th>상품이지</th>
			<th>상품정보</th>
			<th>수량</th>
			<th>상품금액</th>
			<th>비고</th>
		</tr>
		<c:choose>
		<c:when test="${CART_LIST == null || CART_LIST.size <= 0}">
		<tr>
			<td colspan="5" bgcolor="#f0f0f0" height="150" align="center">장바구니에 담은 상품이 없습니다.</td>
		</tr>
		</c:when>
		<c:otherwise>
		<!-- 반복 시작 -->
		<c:forEach var="cnt" begin="0" end="${CART_LIST.size - 1 }">
		<form action="modify-cart" method="post">
		<input type="hidden" name="CODE" value="${CART_LIST.gs_codeList[cnt] }" />
		<tr>
			<td width="100"><img src="/Dmyna/goods/upload/small.${CART_LIST.gs_imgList[cnt]}" width="100" height="100"/></td>
			<td align="center">
				<a href="javascript:goView('${CART_LIST.gs_codeList[cnt] }')">${CART_LIST.gs_nameList[cnt] }</a>
				<br />색상 : ${CART_LIST.color_codeList[cnt] } / 사이즈 : ${CART_LIST.size_codeList[cnt] }
			</td>
			<td width="100" align="center">
				<input type="text" name="NUMBER" size="3" value="${CART_LIST.numberList[cnt] }"/><br /><br />
				<input type="submit" name="BUTTONS" value="변경" />
			</td>
			<td width="100" align="center"><font ><fmt:formatNumber value="${CART_LIST.gs_sale_priceList[cnt] }" type="number"/></font></td>
			<td width="150" align="center">
				<input type="submit" name="BUTTONS" value="삭제하기" size="3" />
			</td>
		</tr>
		</form>
		<c:if test="${cnt == 0 }">
		<c:set var="cartListCode" value="${cartListCode }${CART_LIST.gs_codeList[cnt] }" />
		<c:set var="cartListCnt" value="${cartListCnt }${CART_LIST.numberList[cnt] }" />
		<c:set var="cartListColor" value="${cartListColor }${CART_LIST.color_codeList[cnt] }" />
		<c:set var="cartListSize" value="${cartListSize }${CART_LIST.size_codeList[cnt] }" />
		</c:if>
		<c:if test="${cnt > 0 }">
		<c:set var="cartListCode" value="${cartListCode }|${CART_LIST.gs_codeList[cnt] }" />
		<c:set var="cartListCnt" value="${cartListCnt }|${CART_LIST.numberList[cnt] }" />
		<c:set var="cartListColor" value="${cartListColor }|${CART_LIST.color_codeList[cnt] }" />
		<c:set var="cartListSize" value="${cartListSize }|${CART_LIST.size_codeList[cnt] }" />
		</c:if>
		</c:forEach>
		<!-- 반복 끝 -->
		</c:otherwise>
		</c:choose>
		</table>

	</td>
</tr>
</table>

<c:if test="${!(CART_LIST == null || CART_LIST.size <= 0)}">
<form action="${WEB_ROOT}/order/orderForm.jsp" name="orderCart" method="post">
<input type="hidden" name="LIST_GS_CODE" value="${cartListCode }">
<input type="hidden" name="LIST_GS_COUNT" value="${cartListCnt }">
<input type="hidden" name="LIST_GS_COLOR" value="${cartListColor }">
<input type="hidden" name="LIST_GS_SIZE" value="${cartListSize }">
<table width="900" align="center">
<tr>
	<td align="center">
		<div
			style="height:34px; background:url(${WEB_ROOT }/img/bbs/title_bg.gif) repeat-x;">
			<div
				style="font-weight: bold; font-size: 14px; margin: 7px 0 0 10px;"
				align="center">&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;결제예정금액 : <fmt:formatNumber value="${CART_LIST.totalAmount }" type="number"/>원&nbsp;&nbsp;
			</div>
		</div>
		<input type="hidden" name="TOTAL_AMOUNT" value="${CART_LIST.totalAmount }"/>

	</td>
	<td align="right">
		<input type="submit" name="BUTTONS" value="주문" size="10" />
	</td>
</tr>
</table>
</form>
</c:if>

<script language="javascript">
function goView(gscode) {
	document.move.action = "${WEB_ROOT }/goods/goodsView.jsp";
	document.move.GS_CODE.value = gscode;
	document.move.submit();
}
</script>
<form name="move" method="post">
<input type="hidden" name="GS_CODE" value="" />
</form>

<br />
<%@ include file="/Dmyna/tail.jsp"%>
